/**
  ******************************************************************************
  * @file    Project/Bsp/Comm.h 
  * @author  zlf
  * @version V1.0.0
  * @date    2016-10-12
  * @brief   Header for Comm.c module
  ******************************************************************************
  */

/* Define to prevent recursive inclusion c-------------------------------------*/
#ifndef    __COMM_H
#define    __COMM_H

/* Includes ------------------------------------------------------------------*/
	#include "main.h"

/* Exported macro ------------------------------------------------------------*/
/* define the rcc clock of COMM */
#define COMM_USART_RCC 			( RCC_APB1Periph_USART2 )
#define COMM_DMA_RCC 			( RCC_AHB1Periph_DMA1 )
	
/* define the gpio of SERVO */
#define COMM_GPIO				( GPIOA )

#define COMM_RXD				( GPIO_Pin_3 )
#define COMM_TXD				( GPIO_Pin_2 )

#define COMM_RXD_PS				( GPIO_PinSource3 )
#define COMM_TXD_PS				( GPIO_PinSource2 )

/* define the usart of SERVO */
#define USART_COMM				( USART2 )
#define DMA_CH_COMM				( DMA_Channel_4 )
#define DMA_STR_TX				( DMA1_Stream6 )
#define DMA_STR_RX				( DMA1_Stream5 )

#define DMA_IT_TX_TCIF			( DMA_IT_TCIF6 )
#define DMA_IT_RX_TCIF			( DMA_IT_TCIF5 )

#define ISR_TX_COMM 			DMA1_Stream6_IRQHandler
#define ISR_RX_COMM				DMA1_Stream5_IRQHandler

/* Exported functions ---------------------------------------------------------*/
typedef  struct{
	void (* init )(void);
	void (* poll )(void);
	void (*send)(void);
}F_COMM_Typedef;

extern F_COMM_Typedef fComm;

#endif /* __COMM_H */

 
